<?php $this->_extends('../_layouts/default_layout');?>
<?php $this->_block('contents');?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript">
get_check = function(){
	var ids = '';
	$("#list").find("input[type='checkbox']").each(function(){
		if ($(this).is(":checked"))
		{
            if (ids)
            {
                 ids += ',';
            }
            ids += $(this).val();
		}
	});
	return ids;
}
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme: 'facebook'});
	var product_categories_data = <?=$product_categories?>;
	$(document).mselect(product_categories_data, 'product_categories_id', 'product_categories_id', "<?=isset($_GET['product_categories_id']) ? $_GET['product_categories_id'] : 0;?>");
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true});
	$("#check_all").click(function(){
		if ($(this).is(":checked"))
		{
			$("#list input[type='checkbox']").attr("checked", true);
		}
		else
		{
			$("#list input[type='checkbox']").attr("checked", false);
		}
	});
	$("#export_check_btn").click(function(){
		var ids = get_check();
		if (ids.length == 0)
		{
			alert("请选择产品");
			return false;
		}
		$("#ids").val(ids);
		$("#action_form").attr("action", "<?=url('Online::EbayProduct/ExportCheck')?>");
		$("#action_form").submit();
	});
	$("#export_search_btn").click(function(){
		$("#action_form").attr("action", "<?=url('Online::EbayProduct/ExportSearch')?>");
		$("#action_form").submit();
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get" action="">
<?include (Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>更新时间</th>
		<td>
			<input type="text" class="datepicker" name="begin_update_time" value="<?=isset($_GET['begin_update_time']) ? $_GET['begin_update_time'] : '';?>"/> to
			<input type="text" class="datepicker" name="end_update_time" value="<?=isset($_GET['end_update_time']) ? $_GET['end_update_time'] : '';?>"/>
		</td>
	</tr>
	<tr>
		<th>SKU</th>
		<td>
			<textarea name="product_number" cols="45" rows="2" ><?=isset($_GET['product_number']) ? $_GET['product_number'] : '';?></textarea>
		</td>
	</tr>
	<tr>
		<th></th>
		<td>说明：多个SKU用英文逗号分开</td>
	</tr>
	<tr>
		<th>产品名称</th>
		<td><input type="text" name="product_name" value="<?=isset($_GET['product_name']) ? $_GET['product_name'] : ''?>" /></td>
	</tr>
	<tr>
		<th>选择分类</th>
		<td><input type="hidden" id="product_categories_id" name="product_categories_id" /></td>
	</tr>
	<tr>
		<th>描述语种</th>
		<td>
			<select name="language">
				<option value="">请选择</option>
				<?foreach (Q::ini('custom_flag/online_ebay_product_language') as $oepl):?>
				<option value="<?=$oepl['value']?>" <?if (isset($_GET['language']) && $_GET['language'] == $oepl['value']):?>selected="selected"<?endif;?>><?=$oepl['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>上传的文件</th>
		<td>
			<select name="file_id">
				<option value=""></option>
				<? foreach ($file as $f):?>
				<option value="<?=$f['id']?>" <?if (isset($_GET['file_id']) and $_GET['file_id'] == $f['id']):?>selected = "selected"<?endif;?>><?=$f['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th></th>
		<td><input type="submit" class="button" value="查询"/></td>
	</tr>
</table>
</form>
</fieldset>
<table class="list_table" width="100%" id="list">
	<tr>
		<th width="80">产品编号</th>
		<th width="260">产品名称</th>
		<th width="140">更新时间</th>	
		<th width="50">语种</th>
		<th width="">标题</th>
		<th width="100">图片</th>
		<th width="60">操作</th>
	</tr>
	<?foreach ($product_info as $pi):?>
	<tr>
		<td><input type="checkbox" value="<?=$pi['id']?>" /> <?=$pi['number']?></td>
		<td><?=$pi['name']?></td>
		<td><?=$pi['update_time']?></td>
		<td><?=Helper_BSS_Normal::getIniOne('online_ebay_product_language', 'value', $pi['language'], 'name')?></td>
		<td><?=$pi['title']?></td>
		<td align="center" valign="middle">
			<?if ($pi['pic_url']):?>
				<?$pretty_photo_number = 0;?>
				<?foreach ($pi['pic_url'] as $ppu):?>
				<a rel="pretty_photo[<?=$pi['id']?>]" href="<?=$ppu?>">
					<?if (! $pretty_photo_number):?><img width="50" src="<?=$ppu?>" /><?endif;?>
				</a>
				<?$pretty_photo_number = 1;?>
				<?endforeach;?>
			<?endif;?>
		</td>
		<td><a href="<?=url('Online::EbayProduct/Edit', array('id' => $pi['id']));?>">编辑</a></td>
	</tr>
	<?endforeach;?>
</table>
<?=$page?>
<table class="list_table">
	<tr>
		<td width="60"><label><input type="checkbox" id="check_all" /> 全选</label></td>
		<td width="40">导出</td>
		<td width="220">
			<input type="button" class="button" value="按勾选" id="export_check_btn" />
			<input type="button" class="button" value="按条件" id="export_search_btn" />
		</td>
	</tr>
</table>
<form id="action_form" action="" method="post">
	<input type="hidden" name="url_arr" value="<?=$url_arr?>" />
	<input type="hidden" name="ids" value="" id="ids" />
</form>
<?php $this->_endblock();?>